<!DOCTYPE html>
<html>
<head>
    <style>
        #box1,#box2 {
            width: 100px;
            height: 100px;
            background: blue;
            color: #fff;

            position: relative;
        }
        #box1 {
            top: 500px;
        }
        #box2 {
            top: 800px;
        }
    </style>
</head>
<body>
    <div id="box1">BOX111</div>
    <div id="box2">BOX222</div>
    <script>
        const intersectionObserver = new IntersectionObserver(
            function (entries) {
                console.log('info:');
                entries.forEach(item => {
                    console.log(item.target, item.intersectionRatio)
                })
            }, {
            threshold: [0.5, 1]
        });

        intersectionObserver.observe( document.querySelector('#box1'));
        intersectionObserver.observe( document.querySelector('#box2'));
    </script>
</body>
</html>
